package org.agony2d.gpu.supportClasses {
	import org.agony2d.core.agony_internal
	import org.agony2d.gpu.core.NodeAA;
	import org.agony2d.gpu.core.WorldAA;
	
	use namespace agony_internal;
	
public class ContainerAABase extends NodeAA {
  
	[Inline]
	final override agony_internal function doUpdateDownward() : void {
		var N_A:Number, N_B:Number
		
		N_A  =  Math.cos(m_rotation * Math.PI / 180)
		N_B  =  Math.sin(m_rotation * Math.PI / 180)
		m_matrix_B.a  =  m_matrix_A.a  =   m_scaleX * N_A
		m_matrix_B.b  =  m_matrix_A.b  =   m_scaleY * N_B
		m_matrix_B.c  =  m_matrix_A.c  =  -m_scaleX * N_B
		m_matrix_B.d  =  m_matrix_A.d  =   m_scaleY * N_A
		if (m_pivotX != 0.0 || m_pivotY != 0.0) {
			m_matrix_B.tx  =  m_matrix_A.tx  =  m_x - m_matrix_B.a * m_pivotX - m_matrix_B.c * m_pivotY
			m_matrix_B.ty  =  m_matrix_A.ty  =  m_y - m_matrix_B.b * m_pivotX - m_matrix_B.d * m_pivotY
		}
		else {
			m_matrix_B.tx  =  m_matrix_A.tx  =  m_x
			m_matrix_B.ty  =  m_matrix_A.ty  =  m_y
		}
	}
	
	[Inline]
	final override agony_internal function doUpdateUpward() : void {
		var node:NodeAA
		
		if (m_altered) {
			this.updateByAlone()
		}
		cachedMatrix.copyFrom(m_matrix_A)
		node = m_parent
		while (node && !(node is WorldAA)) {
			if (node.m_altered) {
				node.updateByAlone()
			}
			cachedMatrix.concat(node.m_matrix_A)
			node = node.m_parent
		}
	}
	
	[Inline]
	final override agony_internal function updateByAlone() : void {
		var N_A:Number, N_B:Number
		
		N_A  =  Math.cos(m_rotation * Math.PI / 180)
		N_B  =  Math.sin(m_rotation * Math.PI / 180)
		m_matrix_A.a  =   m_scaleX * N_A
		m_matrix_A.b  =   m_scaleY * N_B
		m_matrix_A.c  =  -m_scaleX * N_B
		m_matrix_A.d  =   m_scaleY * N_A
		if (m_pivotX != 0.0 || m_pivotY != 0.0) {
			m_matrix_A.tx  =  m_x - m_matrix_B.a * m_pivotX - m_matrix_B.c * m_pivotY
			m_matrix_A.ty  =  m_y - m_matrix_B.b * m_pivotX - m_matrix_B.d * m_pivotY
		}
		else {
			m_matrix_A.tx  =  m_x
			m_matrix_A.ty  =  m_y
		}
	}
}
}